package com.zhi.dao;

import com.zhi.entity.Grade;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 院系班级对象dao层,与数据库交互
 */
public interface GradeRepository extends JpaRepository<Grade, String>{


	@Query("SELECT a.id,a.username,a.password,a.userType FROM User a")
	public List<Object[]> getEntityListWithCodeName();
	
	@Query(value = "SELECT a.grade_Id,(select b.faculty_name from faculty b where b.faculty_id=a.faculty_id) faculty_Id,a.grade_Name,(SELECT b.name from teacher b where b.teacher_id=a.instructor) instructor from Grade a",
			countQuery ="select count(*) from Grade",
			nativeQuery = true)
	public Page<Grade> getEntityListWithCodeName(Pageable pageable);

}
